package com.wavecoler.professor.objects;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
@SuppressWarnings("serial")
public class User implements Serializable {
	
	private String encodedKey;
	private String userId;
	private String userName;
	private String firstName;
	private String middleName;
	private String lastName;
	private char gender;
	private boolean active;
	private boolean online;
	private String userType;
	private String password;
	private String birthDay;
	private String birthMonth;
	private String birthYear;
	private int teamId;
	
	public User() {
	}

	public User(String userName, String userType) {
		this.userName = userName;
		this.userType = userType;
	}

	public User(String userid, String userName, String firstName, String middleName,
			String lastName, char gender, boolean active,
			boolean online, String userType) {
		this.userId = userid;
		this.userName = userName;
		this.firstName = firstName;
		this.middleName = middleName;
		this.lastName = lastName;
		this.gender = gender;
		this.active = active;
		this.online = online;
		this.userType = userType;

	}

	// Getters & Setters

	public String getEncodedKey() {
		return encodedKey;
	}
	public String getUserId() {
		return userId;
	}
	
	public void setUserId(String userId) {
		this.userId= userId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getMiddleName() {
		return middleName;
	}

	public void setMiddleName(String middleName) {
		this.middleName = middleName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public char getGender() {
		return gender;
	}

	public void setGender(char gender) {
		this.gender = gender;
	}

	public Date getDateOfBirth() {
		Date convertedDate = null;
	    try {
		 SimpleDateFormat sdf= new SimpleDateFormat("dd/MM/yyyy");
		 convertedDate = sdf.parse(getBirthDay() + "/"+ getBirthMonth() + "/" + getBirthYear());
	    } catch (Exception e) {
	    	e.printStackTrace();
	    }
	    return convertedDate;
	}

	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	public boolean isOnline() {
		return online;
	}

	public void setOnline(boolean online) {
		this.online = online;
	}

	public String getUserType() {
		return userType;
	}

	public void setUserType(String userType) {
		this.userType = userType;
	}

	public String getPassword() {
		return password;
	}
	
	public void setPassword(String pass) {
		this.password = pass;
	}

	public String getBirthDay() {
		return birthDay;
	}

	public void setBirthDay(String birthDay) {
		this.birthDay = birthDay;
	}

	public String getBirthMonth() {
		return birthMonth;
	}

	public void setBirthMonth(String birthMonth) {
		this.birthMonth = birthMonth;
	}

	public String getBirthYear() {
		return birthYear;
	}
	
	public void setBirthYear(String birthYear){
		this.birthYear = birthYear;
	}

	public int getTeamId() {
		return teamId;
	}
	
	public void setTeamId(int teamId){
		this.teamId = teamId;
	}
	
	public String toString() {
		return getUserId()+" "+getUserName()+" "+getFirstName()+" "+getLastName()+" "+getGender()+" UserType= "+getUserType()+
		       " Date of Birth="+getDateOfBirth()+" Active="+isActive()+" On line="+isOnline();
	}


}